package com.wen.task.baseTasks;

import com.wen.moudle.Account;
import com.wen.moudle.Managers.BackpackManager;
import com.wen.moudle.Managers.FightManager;
import com.wen.moudle.Managers.InformationManager;
import com.wen.task.AbstractTask;
import lombok.extern.slf4j.Slf4j;

// 自动打经验宝宝
@Slf4j
public class FightBabyTask extends AbstractTask {
    private InformationManager informationManager;
    private BackpackManager backpackManager;
    private FightManager fightManager;
    public FightBabyTask(Account account) {
        super(account);
        informationManager = getInformationManager();
        backpackManager = getBackpackManager();
        fightManager = getFightManager();
    }

    @Override
    public String getTitle() {
        return "一键打经验宝宝";
    }

    @Override
    public void run() {
        log.info("开始打经验宝宝,请等待");
        Integer physical = informationManager.getPhysical();
        for (int i = 0; i < physical/10; i++) {
            fightManager.fightBaby();
        }
        log.info("体力不足, 使用大体力药剂" );
        Integer bigPotionId = backpackManager.getGoodId("大体力药剂");
        Integer smallPotionId = backpackManager.getGoodId("小体力药剂");
        while (backpackManager.useGood(bigPotionId).isSuccess()){
            for (int i = 0; i < 3; i++) {
                fightManager.fightBaby();
            }
        }
        log.info("大体力药剂使用达到上限，, 使用小体力药剂" );
        while (backpackManager.useGood(smallPotionId).isSuccess()){
            for (int i = 0; i < 3; i++) {
                fightManager.fightBaby();
            }
        }
        log.info("小体力药剂使用达到上限，退出战斗" );
    }
}
